<!--
 * @Description: 个人
 * @Author: tianhao
 * @Date: 2022-07-01 10:10:11
 * @LastEditors: tianhao
 * @LastEditTime: 2023-02-02 09:00:02
-->
<template>
  <div class="address">
    <van-nav-bar
      class="myNavBar"
      title="新增地址"
      left-arrow
      @click-left="goBack()"
    >
    </van-nav-bar>

    <van-address-edit
    
      class="xinjian"
      :area-list="areaList"
      show-postal
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete" 
      
    />
  </div>
</template>
<script setup>
import { areaList } from "@vant/area-data";
import { useRouter } from "vue-router";
import { ref } from "vue";
import {  Toast,AddressEdit} from "vant";




const router = useRouter();
const goBack = () => {
  router.push("address");
};
const searchResult = ref([]);

const onDelete = () => Toast("delete");
// const onChangeDetail = (val) => {
//   if (val) {
//     searchResult.value = [
//       {
//         name: "黄龙万科中心",
//         address: "杭州市西湖区",
//       },
//     ];
//   } else {
//     searchResult.value = [];
//   }
// };
let content = AddressEdit.content
// const name = content.name
// sessionStorage.setItem( 'addaddress' ,JSON.stringify([]))
// const {content} = JSON.parse(
//   sessionStorage.getItem("addaddress")
// );
// const show = ref(false);
// const addressInfo = AddressEdit.addressInfo
const onSave = () => {
  // const address = sessionStorage.getItem("address");
  //   // 加入购物车
  //   Toast("保存成功");
  //   let shopping = JSON.stringify([{ name, tel, address }]);
  //   let oldShopping = sessionStorage.getItem("address");
  //   if (oldShopping === null) {
  //     sessionStorage.setItem("address", shopping);
  //   } 
onSave(content);
sessionStorage.setItem( 'address', JSON.stringify([{content}]));
  }
  // show.value = false;

</script>
<style lang="less" scoped>
.button {
  margin-top: 250px;
  size: large;
  background-color: white;
  color: brown;
  width: 320px;
  border-color: brown;
}
.img {
  width: 100px;
  height: 100px;
  margin-top: 200px;
}
.word {
  font-size: 10px;
  margin-top: 10px;
}
.xinjian {
  position: absolute;
  top: 40px;
  width: 350px;
  height: 600px;
  background-color: #faebd7;
}
</style>
